import java.util.HashMap;

public class ConcreteMediator implements Mediator{
    private HashMap<String,Colleague> colleagues;


    public ConcreteMediator(){
        colleagues = new HashMap<>();
    }


    @Override
    public void resister(String name, Colleague colleague) {
        colleagues.put(name,colleague);
    }

    @Override
    public void getMessage(int stateChange, String name) {
        if (colleagues.containsKey(name)&&colleagues.get(name) instanceof TV){
            if (stateChange==1)
            {
                ((TV) colleagues.get(name)).openTV();
                ((CoffeeMa)colleagues.get("CoffeeMa")).openCoffeeMa();
            }
            if (stateChange==2)
            {
                ((TV) colleagues.get(name)).closeTV();
            }

        }
    }

}
